//
//  TJHomeTitleBtn.swift
//  TJSinaWeibo
//
//  Created by 唐后能 on 16/4/12.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

class TJHomeTitleBtn: UIButton {
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        // 让文字在最左边.
        titleLabel?.frame.origin.x = 0
        
        // 让图片的X值等于文字的宽度
        imageView?.frame.origin.x = (titleLabel?.frame.size.width)! + 5
        
    }
    init(title:String,imgName:String,highlightImgName:String?){
        
        super.init(frame:CGRectZero)
        setImage(UIImage(named: imgName), forState: UIControlState.Normal)
        setTitle(title, forState: .Normal)
        setTitleColor(UIColor.blackColor(), forState: .Normal)
        sizeToFit()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
